package com.baor.controller;

import com.baor.domain.VersionConfig;
import com.baor.service.VersionConfigService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/version")
public class VersionConfigController {
    @Resource
    private VersionConfigService versionConfigService;

    @GetMapping("/list")
    public Map<String, Object> getVersionList() {
        Map<String, Object> result = new HashMap<>();
        result.put("qygiAndroid", versionConfigService.getByAppType("清运管家安卓"));
        result.put("zkV1", versionConfigService.getByAppType("中控端v1"));
        result.put("zkV4", versionConfigService.getByAppType("中控端v4"));
        result.put("fqRecycleAndroid", versionConfigService.getByAppType("房启回收安卓"));
        result.put("fqRecycleIos", versionConfigService.getByAppType("房启回收ios"));
        return result;
    }

    @PostMapping("/update")
    public boolean updateVersion(@RequestBody VersionConfig versionConfig) {
        return versionConfigService.updateVersion(versionConfig);
    }
}
